﻿using EkStudio.com.bean.xml.reflection;
using EkStudio.com.bean.xml.Unit;

namespace EkStudio.com.bean.xml.RootInterface.FieldEvent
{
    public class BillDataFillItem:BillUiFormatNode
    {
        private string key = BeanUtil.EVENT_KEY_VALUE;
        private string caption = BeanUtil.EVENT_CAPTION_VALUE;
        private string languageTexts;
        private string fillType = BeanUtil.EVENT_TYPE_VALUE;
        private string _event = "";//绑定字段
        private bool eventType = false;
        private string targetTable = "";
        private bool coverWrite = true;

        private BillDataFillsqlSource sqlSource;
        private BillDataFillsqlWhere sqlWhere;
        private BillDataFillSqlValue sqlValue;


        [Xml("caption")]
        public string Caption
        {
            get
            {
                return caption;
            }

            set
            {
                caption = value;
            }
        }

        [Xml("key")]
        public string Key
        {
            get
            {
                return key;
            }

            set
            {
                key = value;
            }
        }
        
        [Xml("languageTexts")]
        public string LanguageTexts
        {
            get
            {
                return languageTexts;
            }

            set
            {
                languageTexts = value;
            }
        }
        /// <summary>
        /// 事件类型  
        /// </summary>
        [Xml("fillType")]
        public string FillType
        {
            get
            {
                return fillType;
            }

            set
            {
                fillType = value;
            }
        }
        [Xml("event")]
        public string Event
        {
            get
            {
                return _event;
            }

            set
            {
                _event = value;
            }
        }
        /// <summary>
        /// 是否填充子表
        /// </summary>
        [Xml("eventType")]
        public bool EventType
        {
            get
            {
                return eventType;
            }

            set
            {
                eventType = value;
            }
        }
        [Xml("targetTable")]
        public string TargetTable
        {
            get
            {
                return targetTable;
            }

            set
            {
                targetTable = value;
            }
        }
        [Xml("coverWrite")]
        public bool CoverWrite
        {
            get
            {
                return coverWrite;
            }

            set
            {
                coverWrite = value;
            }
        }
        [XmlElement("sql")]
        public BillDataFillsqlSource SqlSource
        {
            get
            {
                return sqlSource;
            }

            set
            {
                sqlSource = value;
            }
        }
        [XmlElement("sqlWhere")]
        public BillDataFillsqlWhere SqlWhere
        {
            get
            {
                return sqlWhere;
            }

            set
            {
                sqlWhere = value;
            }
        }
        [XmlElement("setValue")]
        public BillDataFillSqlValue SqlValue
        {
            get
            {
                return sqlValue;
            }

            set
            {
                sqlValue = value;
            }
        }
        [XmlTransient]
        public object ParentBean
        {
            get
            {
                return null;
            }

            set
            {
                
            }
        }

        public object Clone()
        {
            BillDataFillItem clone = new BillDataFillItem();
            clone.Key  = key;
            clone.Caption = Caption;
            clone.CoverWrite = CoverWrite;
            clone.FillType = FillType;
            clone.Event  = Event;
            clone.EventType = this.eventType;
            clone.TargetTable = this.targetTable;
            if (this.sqlSource != null)
            {
                clone.SqlSource = (BillDataFillsqlSource)sqlSource.Clone();
            }
            if (this.sqlWhere != null)
            {
                clone.SqlWhere = (BillDataFillsqlWhere)sqlWhere.Clone();
            }
            if (this.SqlValue != null)
            {
                clone.sqlValue = ((BillDataFillSqlValue)sqlValue.Clone());
            }
            

            return clone;
        }
    }
}
